package com.yuju.util;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Row.MissingCellPolicy;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

/**
 * excel工具类 支持2003、2007、2010、2013
 * 
 * @author liubenlong
 * 
 */
public class ExcelImp {

	private Workbook wb = null;
	private Sheet[] sheet = null;
	private Sheet singleSheet = null;

	/**
	 * 模版文件路径
	 */
	private String templateFilePath;
	/**
	 * sheet的总数
	 */
	private int sheetNo;
	/**
	 * 总行数 最大行的index值，实际行数要加1
	 */
	private int rowNum = 0;
	/**
	 * 总列数
	 */
	private int columnNum = 0;
    /** 
     * 字节流 
     */  
    private OutputStream fileOutput;
    
    /**
     * 构造Excel
     * @author xue
     * @date 2016-07-09
     * @param in 文件流
     */
    public ExcelImp(InputStream in) {
		init(in);
    }

	/**
	 * 初始化
	 * @author xue
	 * @update 2016-07-09
	 * @param filePath
	 * @param sheetIndex
	 *            <p>
	 *            默认第一个sheet
	 *            </p>
	 */
	public ExcelImp(String filePath) {
		try {
			InputStream in = new FileInputStream(filePath);
			init(in);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	/**
	 * 初始化Excel文档
	 * @author xue
	 * @date 2016-07-09
	 * @param in 文件流
	 */
	public void init(InputStream in) {
		try {
			wb = WorkbookFactory.create(in);
			
			sheetNo = wb.getNumberOfSheets();

			//this.sheet = wb.getSheetAt(sheetIndex);
			this.sheet = new Sheet[sheetNo];
			for(int s=0; s<sheetNo; s++) {
				this.sheet[s] = wb.getSheetAt(s);
				rowNum += sheet[s].getLastRowNum();
			}

			if (sheet[0].getRow(0) != null) {
				columnNum = sheet[0].getRow(0).getLastCellNum();
			}

			System.out.println("共" + sheetNo + "个sheet；总行数：" + rowNum
					+ "；总列数：" + columnNum);

		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (InvalidFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
    }
	
	/**
	 * 初始化
	 * @author xue
	 * @update 2016-07-09
	 * @param filePath
	 * @param sheetIndex
	 *            <p>
	 *            默认第一个sheet
	 *            </p>
	 */
	public ExcelImp(String filePath, int sheetIndex) {
		try {
			InputStream inp = new FileInputStream(filePath);
			wb = WorkbookFactory.create(inp);
			
			this.singleSheet = wb.getSheetAt(sheetIndex);

			rowNum = this.singleSheet.getLastRowNum();

			if (this.singleSheet.getRow(0) != null) {
				columnNum = this.singleSheet.getRow(0).getLastCellNum();
			}

			System.out.println("第" + sheetIndex + "个工作薄；总行数：" + rowNum
					+ "；总列数：" + columnNum);

		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (InvalidFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public ExcelImp() {}

	/**
	 * 取Excel所有数据，包含header
	 * @author xue
	 * @update 2016-07-09
	 * @return List<String[]>
	 */
	public List<String[]> getAllData() {
		List<String[]> dataList = new ArrayList<String[]>();
		if (columnNum > 0) {
			for (int i = 0; i < rowNum + 1; i++) {
				String[] singleRow = new String[columnNum];
				for (int j = 0; j < columnNum; j++) {
					singleRow[j] = getCellVal(i, j);
				}
				dataList.add(singleRow);
			}
		}
		return dataList;
	}

	/**
	 * 取Excel所有数据，包含header
	 * @author xue
	 * @update 2016-07-09
	 * @return List<String[]>
	 */
	public List<List<List<String>>> getAllSheetData() {
		List<List<List<String>>> sheetList = new ArrayList<List<List<String>>>();
		for(int s=0; s<sheetNo; s++) {
			int rowNo = sheet[s].getLastRowNum();
			System.out.println("第" + s + "个sheet的总行数：" + rowNo);
			if(rowNo == 0)
				continue ;
			// 行数从1开始，过滤掉头部
			List<List<String>> rowList = new ArrayList<List<String>>();
			for (int i = 1; i < rowNo+1; i++) {
				List<String> singleRow = new ArrayList<String>();//[sheet[s].getRow(0).getLastCellNum()];
				for (int j = 0; j < sheet[s].getRow(0).getLastCellNum(); j++) {
					//singleRow[j] = getCellVal(s, i, j);
					singleRow.add(getCellVal(s, i, j));
				}
				rowList.add(singleRow);
			}
			sheetList.add(rowList);
		}
		return sheetList;
	}

	/**
	 * 获取单元格数据
	 * @author xue
	 * @update 2016-07-09
	 * @param columnNum
	 *            <P>
	 *            从0开始
	 *            </P>
	 * @param row
	 *            <P>
	 *            从0开始
	 *            </P>
	 * @return
	 */
	public String getCellVal(int sheetNo, int rowNum, int columnNum) {

		String cellVal = null;
		Cell cell = sheet[sheetNo].getRow(rowNum).getCell(columnNum,
				MissingCellPolicy.CREATE_NULL_AS_BLANK);
		switch (cell.getCellType()) {
		case Cell.CELL_TYPE_BLANK:
			cellVal = "";
			break;
		case Cell.CELL_TYPE_BOOLEAN:
			cellVal = Boolean.toString(cell.getBooleanCellValue());
			break;
		// 数值
		case Cell.CELL_TYPE_NUMERIC:
			if (DateUtil.isCellDateFormatted(cell)) {
				cellVal = String.valueOf(cell.getDateCellValue());
			} else {
				cell.setCellType(Cell.CELL_TYPE_STRING);
				String temp = cell.getStringCellValue();
				// 判断是否包含小数点，如果不含小数点，则以字符串读取，如果含小数点，则转换为Double类型的字符串
				if (temp.indexOf(".") > -1) {
					cellVal = String.valueOf(new Double(temp)).trim();
				} else {
					cellVal = temp.trim();
				}
			}
			break;
		case Cell.CELL_TYPE_STRING:
			cellVal = cell.getStringCellValue().trim();
			break;
		case Cell.CELL_TYPE_ERROR:
			cellVal = "";
			break;
		case Cell.CELL_TYPE_FORMULA:
			cell.setCellType(Cell.CELL_TYPE_STRING);
			cellVal = cell.getStringCellValue();
			if (cellVal != null) {
				cellVal = cellVal.replaceAll("#N/A", "").trim();
			}
			break;
		default:
			cellVal = "";
			break;
		}
		return cellVal;
	}

	/**
	 * 获取单元格数据
	 * @author xue
	 * @update 2016-07-09
	 * @param columnNum
	 *            <P>
	 *            从0开始
	 *            </P>
	 * @param row
	 *            <P>
	 *            从0开始
	 *            </P>
	 * @return
	 */
	public String getCellVal(int rowNum, int columnNum) {

		String cellVal = null;
		Cell cell = singleSheet.getRow(rowNum).getCell(columnNum,
				MissingCellPolicy.CREATE_NULL_AS_BLANK);
		switch (cell.getCellType()) {
		case Cell.CELL_TYPE_BLANK:
			cellVal = "";
			break;
		case Cell.CELL_TYPE_BOOLEAN:
			cellVal = Boolean.toString(cell.getBooleanCellValue());
			break;
		// 数值
		case Cell.CELL_TYPE_NUMERIC:
			if (DateUtil.isCellDateFormatted(cell)) {
				cellVal = String.valueOf(cell.getDateCellValue());
			} else {
				cell.setCellType(Cell.CELL_TYPE_STRING);
				String temp = cell.getStringCellValue();
				// 判断是否包含小数点，如果不含小数点，则以字符串读取，如果含小数点，则转换为Double类型的字符串
				if (temp.indexOf(".") > -1) {
					cellVal = String.valueOf(new Double(temp)).trim();
				} else {
					cellVal = temp.trim();
				}
			}
			break;
		case Cell.CELL_TYPE_STRING:
			cellVal = cell.getStringCellValue().trim();
			break;
		case Cell.CELL_TYPE_ERROR:
			cellVal = "";
			break;
		case Cell.CELL_TYPE_FORMULA:
			cell.setCellType(Cell.CELL_TYPE_STRING);
			cellVal = cell.getStringCellValue();
			if (cellVal != null) {
				cellVal = cellVal.replaceAll("#N/A", "").trim();
			}
			break;
		default:
			cellVal = "";
			break;
		}
		return cellVal;
	}

	/**
	 * 设置单元格数据 下标从0开使
	 * @author xue
	 * @update 2016-07-09
	 * @param rownum
	 * @param column
	 * @param value
	 */
	public void setCellVal(int rownum, int column, String value) {
		singleSheet.getRow(rownum).getCell(column).setCellValue(value);
	}

	/**
	 * 设置单元格数据 下标从0开使
	 * @author xue
	 * @update 2016-07-09
	 * @param rownum
	 * @param column
	 * @param value
	 */
	public void setCellVal(int sheetNo, int rownum, int column, String value) {
		sheet[sheetNo].getRow(rownum).getCell(column).setCellValue(value);
	}

	/**
	 * 保存修改后的 文件
	 * @author xue
	 * @update 2016-07-09
	 * @param newFilePath
	 *            <P>
	 *            文件绝对路径
	 *            </P>
	 * @throws IOException
	 */
	public void saveNewFile(String newFilePath) throws IOException {
		FileOutputStream out = new FileOutputStream(newFilePath);
		out.flush();
		wb.write(out);
		out.close();
	}

	/**
	 * 获取某一行数据
	 * @author xue
	 * @update 2016-07-09
	 * @param rowIndex
	 *            计数从0开始，rowIndex为0代表header行
	 * @return
	 */
	public String[] getRowData(int sheetNo, int rowIndex) {
		String[] dataArray = null;
		if (rowIndex > columnNum) {
			return dataArray;
		} else {
			String[] singleRow = new String[columnNum];
			for (int j = 0; j < columnNum; j++) {
				singleRow[j] = getCellVal(sheetNo, rowIndex, j);
			}
			return singleRow;
		}
	}

	/**
	 * 获取某一行数据
	 * @author xue
	 * @update 2016-07-09
	 * @param rowIndex
	 *            计数从0开始，rowIndex为0代表header行
	 * @return
	 */
	public String[] getRowData(int rowIndex) {
		String[] dataArray = null;
		if (rowIndex > columnNum) {
			return dataArray;
		} else {
			String[] singleRow = new String[columnNum];
			for (int j = 0; j < columnNum; j++) {
				singleRow[j] = getCellVal(rowIndex, j);
			}
			return singleRow;
		}
	}

	/**
	 * 获取某一列数据
	 * @author xue
	 * @update 2016-07-09
	 * @param colIndex
	 * @return
	 */
	public String[] getColumnData(int sheetNo, int columnIndex) {
		String[] dataArray = new String[rowNum + 1];
		if (columnIndex > columnNum) {
			return dataArray;
		} else {
			for (int i = 0; i < rowNum + 1; i++) {
				dataArray[i] = getCellVal(sheetNo, i, columnIndex);
			}
		}
		return dataArray;
	}

	/**
	 * 获取某一列数据
	 * @author xue
	 * @update 2016-07-09
	 * @param colIndex
	 * @return
	 */
	public String[] getColumnData(int columnIndex) {
		String[] dataArray = new String[rowNum + 1];
		if (columnIndex > columnNum) {
			return dataArray;
		} else {
			for (int i = 0; i < rowNum + 1; i++) {
				dataArray[i] = getCellVal(i, columnIndex);
			}
		}
		return dataArray;
	}

	/**
	 * 目前只支持一行表头的Excel
	 * @author xue
	 * @update 2016-07-09
	 * @param headList
	 * @param headstyle
	 * @param bodyList
	 * @param bodystyle
	 * @throws IOException
	 */
	@Deprecated
	public void create2007(String filePath, List<String> headList,
			HSSFCellStyle headstyle, List<String[]> bodyList,
			HSSFCellStyle bodystyle) throws IOException {
		XSSFWorkbook workbook = new XSSFWorkbook();
		XSSFSheet sheet = workbook.createSheet();

		XSSFRow headRow = sheet.createRow(0);
		for (int i = 0; i < headList.size(); i++) {
			XSSFCell cell = headRow.createCell(i);
			cell.setCellValue(headList.get(i));
			if (null != headstyle)
				cell.setCellStyle(headstyle);
		}

		for (int i = 1; i < bodyList.size() + 1; i++) {
			XSSFRow row = sheet.createRow(i);
			for (int j = 0; j < bodyList.get(i - 1).length; j++) {
				XSSFCell cell = row.createCell(j);
				cell.setCellValue(bodyList.get(i - 1)[j]);
				if (null != bodystyle)
					cell.setCellStyle(bodystyle);
			}
		}

		FileOutputStream out = new FileOutputStream(new File(filePath));
		workbook.write(out);
		out.close();

	}

	/**
	 * 目前只支持一行表头的Excel
	 * @author xue
	 * @update 2016-07-09
	 * @param headList
	 * @param headstyle
	 * @param bodyList
	 * @param bodystyle
	 * @throws IOException
	 */
	@Deprecated
	public void create2003(String filePath, List<String> headList,
			HSSFCellStyle headstyle, List<String[]> bodyList,
			HSSFCellStyle bodystyle) throws IOException {
		HSSFWorkbook workbook = new HSSFWorkbook();
		HSSFSheet sheet = workbook.createSheet();

		HSSFRow headRow = sheet.createRow(0);

		for (int i = 0; i < headList.size(); i++) {
			HSSFCell cell = headRow.createCell(i);
			cell.setCellValue(headList.get(i));
			if (null != headstyle)
				cell.setCellStyle(headstyle);
		}

		for (int i = 1; i < bodyList.size() + 1; i++) {
			HSSFRow row = sheet.createRow(i);
			for (int j = 0; j < bodyList.get(i - 1).length; j++) {
				HSSFCell cell = row.createCell(j);
				cell.setCellValue(bodyList.get(i - 1)[j]);
				if (null != bodystyle)
					cell.setCellStyle(bodystyle);
			}
		}

		FileOutputStream out = new FileOutputStream(new File(filePath));
		workbook.write(out);
		out.close();
	}
	
	/**
	 * 创建excel文档
	 * @author xue
	 * @update 2016-07-09
	 * @param tName
	 * @param tHeader
	 * @param tValue
	 * @param tHeaderStyle
	 * @param tValueStyle
	 * @param filePath
	 */
	public void exportExcel(String tName, ArrayList<String> tHeader, List<ArrayList<Object>> tValue,  
            Map<String, Short> tHeaderStyle, Map<String, Short> tValueStyle, String filePath) {
		try {  
            // 当excel文档不存在时创建  
			wb = new HSSFWorkbook();
  
            // 单个表单赋值和样式  
            this.setSheet(tName, tHeader, tValue, tHeaderStyle, tValueStyle);  
            // 导出excel文件  
            this.export(wb, filePath);  
  
        } catch (Exception e) {  
            e.printStackTrace();  
  
        }
	}
	
	/** 
     * @功能描述 设置excel表单 
	 * @author xue
	 * @update 2016-07-09
     * @param tName 
     *            excel表名 
     * @param tHeader 
     *            excel表头数据集 
     * @param tValue 
     *            excel表单数据集(除表头) 
     * @param tHeaderStyle 
     *            excel表头单元格样式 
     * @param tValueStyle 
     *            excel表单数据单元格样式(除表头) 
     * @throws Exception 
     *             异常往上抛出 
     */  
    private void setSheet(String tName, ArrayList<String> tHeader, List<ArrayList<Object>> tValue,  
            Map<String, Short> tHeaderStyle, Map<String, Short> tValueStyle) throws Exception {  
  
        try {  
            // 创建表单并设置其表名  
            singleSheet = wb.createSheet(tName);  
  
            // 创建表单行  
            HSSFRow tRow = (HSSFRow) singleSheet.createRow(0);
  
            // 赋值和样式(此时,为表头行)  
            tRow = this.setTRow(tRow, tHeader, tHeaderStyle);  
  
            // for循环完成表单数据的赋值和样式(除表头)  
            for (int i = 0; i < tValue.size(); i++) {  
                tRow = (HSSFRow) singleSheet.createRow(i + 1); // 获取表单行  
  
                tRow = this.setTRow(tRow, tValue.get(i), tValueStyle); // 设置当前行的数据和样式  
            }  
        } catch (Exception e) {  
            e.printStackTrace();  
        }  
    }  
  
    /** 
     * @功能描述 设置excel表单行数据 
	 * @author xue
	 * @update 2016-07-09
     * @param row 
     *            excel表单行 
     * @param tRow 
     *            excel表单行数据 
     * @param tHeaderStyle 
     *            excel表头样式 
     * @return 设置后的的表单行 
     * @throws Exception 
     *             异常往外抛出 
     */  
    private HSSFRow setTRow(HSSFRow row, ArrayList tRow, Map<String, Short> tHeaderStyle) throws Exception {  
  
        try {  
            // 获取单元格样式  
            HSSFCellStyle cellStyle = this.setCellStyle(tHeaderStyle);  
            // 声明单元格  
            HSSFCell cell = null;  
  
            // for循环完成该表单某行各个列赋值和样式  
            for (int i = 0; i < tRow.size(); i++) {  
                cell = row.createCell(i); // 获取每列单元格  
                cell.setCellStyle(cellStyle); // 设置样式  
  
                singleSheet.autoSizeColumn((short) i); // 设置单元格自适应  
                Object obj = tRow.get(i); // 获取当前列的值  
                // 判断对象所属类型, 并强转  
                if (obj instanceof Integer) // 当数字时  
                    cell.setCellValue((Integer) obj);  
                if (obj instanceof String) // 当为字符串时  
                    cell.setCellValue((String) obj);  
                if (obj instanceof Boolean) // 当为布尔时  
                    cell.setCellValue((Boolean) obj);  
                if (obj instanceof Date) // 当为时间时  
                    cell.setCellValue((Date) obj);  
                if (obj instanceof Calendar) // 当为时间时  
                    cell.setCellValue((Calendar) obj);  
                if (obj instanceof Double) // 当为小数时  
                    cell.setCellValue((Double) obj);  
            }  
        } catch (Exception e) {  
            e.printStackTrace();  
        }  
        return row; // 返回  
    } 
  
    /** 
     * @功能描述 设置单元格样式 
	 * @author xue
	 * @update 2016-07-09
     * @param fontStyle 
     *            样式Map集合 
     * @return 设置后单元格样式 
     * @throws Exception 
     *             异常往外抛出 
     */  
    private HSSFCellStyle setCellStyle(Map<String, Short> fontStyle) throws Exception {  
  
        // 声明单元格样式  
        HSSFCellStyle cellStyle = null;  
        try {  
            // 创建字体  
            HSSFFont font = (HSSFFont) wb.createFont();  
            // 设置字体样式  
            // 设置字体颜色(红色为:HSSFFont.COLOR_RED 这里表示short类型 10)  
            font.setColor(fontStyle.get("color"));  
            // 设置字体形体(宽体为:HSSFFont.BOLDWEIGHT_BOLD 700) -- 粗体  
            //font.setBoldweight(fontStyle.get("weight"));  
            font.setBold(true);
  
            // 创建单元格样式  
            cellStyle = (HSSFCellStyle) wb.createCellStyle();  
            // 添加字体样式  
            cellStyle.setFont(font);  
  
        } catch (Exception e) {  
            e.printStackTrace();  
        }  
        return cellStyle; // 返回  
    } 
  
    /** 
     * @功能描述 导出Excel 
	 * @author xue
	 * @update 2016-07-09
     * @param workbook 
     *            excel文档 
     * @param filePath 
     *            xls文件地址 
     * @throws Exception 
     *             异常往外抛出 
     */  
    private void export(Workbook workbook, String filePath) throws Exception {  
  
        try {  
            // 根据指定xls文件创建文件字符流  
            fileOutput = new FileOutputStream(filePath);  
            // 将文档写入指定文件  
            workbook.write(fileOutput);  
  
        } catch (FileNotFoundException e) {  
            e.printStackTrace();  
        } catch (Exception e) {  
            e.printStackTrace();  
        } finally {  
            try {  
                // 关闭流, 释放资源  
                fileOutput.close();  
            } catch (IOException e) {  
                e.printStackTrace();  
                ;  
            }  
        }  
    }  
  
    /** 
     * @功能描述 获取流 
	 * @author xue
	 * @update 2016-07-09
     * @param workbook 
     *            excel文档 
     * @throws Exception 
     *             异常往外抛出 
     */  
    private InputStream export(HSSFWorkbook workbook) throws IOException {  
  
        ByteArrayOutputStream baos = new ByteArrayOutputStream();  
        try {  
            try {
                workbook.write(baos);  
            } catch (IOException e) {
                e.printStackTrace();  
            }  
            byte[] ba = baos.toByteArray();  
            ByteArrayInputStream bais = new ByteArrayInputStream(ba);  
            return bais;  
        } finally {  
            // 关闭流, 释放资源  
            baos.close();  
        }  
    }

	public Workbook getWb() {
		return wb;
	}

	public void setWb(Workbook wb) {
		this.wb = wb;
	}

	public Sheet[] getSheet() {
		return sheet;
	}

	public void setSheet(Sheet[] sheet) {
		this.sheet = sheet;
	}

	public Sheet getSingleSheet() {
		return singleSheet;
	}


	public void setSingleSheet(Sheet singleSheet) {
		this.singleSheet = singleSheet;
	}


	/**
	 * 获取总行数 最大行的index值，实际行数要加1
	 * 
	 * @return
	 */
	public int getRowNum() {
		return rowNum;
	}

	public int getColumnNum() {
		return columnNum;
	}

	public String getTemplateFilePath() {
		return templateFilePath;
	}

	public int getSheetNo() {
		return sheetNo;
	}


	public void setSheetNo(int sheetNo) {
		this.sheetNo = sheetNo;
	}


	public void setTemplateFilePath(String templateFilePath) {
		this.templateFilePath = templateFilePath;
	}


	public void setRowNum(int rowNum) {
		this.rowNum = rowNum;
	}


	public void setColumnNum(int columnNum) {
		this.columnNum = columnNum;
	}


	public static void main(String[] args) throws IOException {
		ExcelImp excelUtil = new ExcelImp("d:/q.xlsx", 0);
		String[] columnData = excelUtil.getRowData(1);
		if(null != columnData)
			for (String string : columnData) {
				System.out.print(string + "\t");
			}
		System.out.println();
		List<List<List<String>>> allRowList = new ArrayList<List<List<String>>>();
		ExcelImp excelUtil2 = new ExcelImp("d:/q.xlsx");
		List<List<List<String>>> allData = excelUtil2.getAllSheetData();
		for(int i=0; i<allData.size(); i++) {
			List<List<String>> rowList = allData.get(i);
			for(int j=0; j<rowList.size(); j++) {
				List<String> cellList = rowList.get(j);
				for(String s : cellList) {
					System.out.print(s + "\t");
				}
				System.out.println();
			}
			allRowList.add(rowList);
			System.out.println("==================sheet" + i + "======================");
		}
		ArrayList<String> tHeader = new ArrayList<String>();
		tHeader.add("商品名称");
		tHeader.add("采购价");
		tHeader.add("零售价");
		tHeader.add("会员价");
		tHeader.add("批发价");
		tHeader.add("市场价");
		tHeader.add("重量");
		tHeader.add("条码值");
		tHeader.add("规格型号");
		tHeader.add("厂家");
		tHeader.add("品牌");
		for(int i=0; i<allRowList.size(); i++) {
			//exportExcel("", tHeader, allRowList.get(i));
		}
	}
}
